<extend name="Layout/ins_page" />
<block name="content">
	{:W('PageHeader/new_search',array('name'=>$folder_name,'search'=>'M'))}
	<form method="post" name="form_adv_search" id="form_adv_search">
		<div class="adv_search panel panel-default <php>echo empty($_REQUEST) ? 'hidden' : '';</php>"  id="adv_search">
			<div class="panel-heading">
				<div class="row">
					<h4 class="col-xs-6">库存查询</h4>
					<div class="col-xs-6 text-right">
						<a  class="btn btn-sm btn-info" onclick="submit_search();">搜索</a>
						<a  class="btn btn-sm btn-info" href="{:U('category')}">重置</a>
					</div>
				</div>
			</div>
			<div class="panel-body">
				<div class="form-group col-sm-6" >
					<label class="col-sm-4 control-label" for="eq_product_type_id">库存类别：</label>
					<div class="col-sm-8">
						<select class="form-control product-type-id" name="product_type_id" >
							<option value="">选择库存类别</option>
							<notempty  name="product_type">
								<foreach name="product_type" item="vo">
									<option value="{$vo['id']}" <if condition="$product_type_id eq $vo['id']">selected="selected"</if>  >{$vo['type_name']}</option>
								</foreach>						
							</notempty >
						</select>
					</div>
				</div>
				<div class="form-group col-sm-6">
					<label class="col-sm-4 control-label" for="product_name">产品名称：</label>
					<div class="col-sm-8">
						<input class="form-control product-name" id="product-name" type="text" name="product_name" value="{$product_name}" />
					</div>
				</div>
			</div>
		</div>
	</form>
	<div class="space-8"></div>
	<div class="ul_table ul_table_responsive">
		<ul>
			<li class="thead">
				<span class="col-8 ">库存类别</span>
				<span class="col-8 ">分类</span>
				<span class="col-10 ">库存总数</span>
				<span class="col-10 ">入库数</span>
				<span class="col-10 ">出库数</span>
			</li>
			<empty name="list">
				<li class="no-data">
					没找到数据
				</li>
				<else/>
				<foreach name="list" item="vo">
					<li class="tbody">
						<span class="col-8"><a href="{:U('product',array('eq_product_type_id'=>$vo['product_type_id']))}">{$vo.product_type_name}</a></span>
						<span class="col-8">
							<php>echo empty($cate[$vo['product_type_id']]) ? '' : $flag[$cate[$vo['product_type_id']]];</php>
						</span>
						<span class="col-10">{$vo.num}</span>
						<span class="col-10">{$vo.in_num}</span>
						<span class="col-10">{$vo.out_num}</span>
					</li>
				</foreach>
				<div class="pagination">
					{$page}
				</div>
			</empty>
		</ul>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		function delProduct(id)	{
			ui_confirm('确定删除吗', function() {
				sendAjax("{:U('delProduct')}",'id='+id, function(data) {
					if (data.status) {
						location.reload(true);
					} else {
						ui_error(data.info);
					}
				});	
			});
		}
		
		// 提交搜索
		function submit_search() {
				
			var product_type_id = $('.product-type-id').val();
			var product_name = $('.product-name').val();
			location.href = "{:U('index')}"+'&product_type_id='+product_type_id+'&product_name='+product_name;
		}
		
	</script>
</block>